package cn.com.haopy.yue.ai.admin.web;


import cn.com.haopy.yue.ai.admin.annotation.RequiresPermissionsDesc;
import cn.com.haopy.yue.ai.core.utils.ResponseUtil;
import cn.com.haopy.yue.ai.db.service.hos.AIRiskPapersIllnessService;
import cn.com.haopy.yue.ai.db.service.hos.HOSUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author keel
 * @date 2022/4/18
 */
@RestController
@RequestMapping("/admin/index")
@RequiredArgsConstructor
@Slf4j
@Api(tags = "首页")
public class AdminIndexController {
    @Autowired
    private AIRiskPapersIllnessService papersIllness;

    @Autowired
    private HOSUserService userService;

    @GetMapping("/index")
    @ApiOperation("测试")
    public Object index() {
        return ResponseUtil.ok("hello world, this is admin service");
    }


    @RequiresPermissions("admin:index:papers:illness:pie:count")
    @RequiresPermissionsDesc(menu = {"首页", "风险统计"}, button = "风险统计")
    @GetMapping("/papers/illness/pie/count")
    @ApiOperation("问卷风险统计")
    public Object pieCount() {
        return ResponseUtil.ok(papersIllness.getPieCount());
    }

    @RequiresPermissions("admin:index:papers:illness:bar:count")
    @RequiresPermissionsDesc(menu = {"首页", "风险疾病统计"}, button = "风险疾病统计")
    @GetMapping("/papers/illness/bar/count")
    @ApiOperation("问卷风险疾病统计")
    public Object barCount(@RequestParam String name) {
        return ResponseUtil.ok(papersIllness.getBarCount(name));
    }

    @RequiresPermissions("admin:index:user:count")
    @RequiresPermissionsDesc(menu = {"首页", "用户统计"}, button = "用户统计")
    @GetMapping("/user/count")
    @ApiOperation("问卷风险疾病统计")
    public Object userCount() {
        return ResponseUtil.ok(userService.getCount());
    }
}
